<template>
  <view class="login-container">
    <view class="login-btns">
      <u-button :customStyle="btnCustomStyle" @click="handleBind"> 绑定用户 </u-button>
    </view>
  </view>
</template>

<script>
import { bindUser } from "@/apis/user"
export default {
  data() {
    return {
      btnCustomStyle: {
        height: "88rpx",
        borderRadius: "20rpx",
        background: "#fff",
        color: "#21897D",
        border: "none",
        fontSize: "34rpx",
      },
    }
  },
  onLoad() {},
  methods: {
    handleBind() {
      dd.getAuthCode({
        corpId: "dingdc2ddfa8e636d3c435c2f4657eb6378f",
        success: (res) => {
          const { authCode } = res
          console.log("authCode :>> ", authCode)
          const data = {
            qzCode: "94b769f6640b4e968f6b2c9b6f8555ed",
            dingCode: authCode,
          }
          bindUser(data).then((res) => {
            uni.showToast({
              title: "绑定成功",
              icon: "none",
            })
            uni.redirectTo({
              url: "/pages/login/login",
            })
          })
        },
        fail: (err) => {
          console.log("err :>> ", err)
        },
        complete: () => {},
      })
    },
  },
  onShow() {},
}
</script>

<style lang="less" scoped>
.login-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  // padding-top: 180rpx;
  background-image: url(../static/images/login-bg.png);
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.login-btns {
  margin-top: 40vh;
  width: 80vw;
  display: flex;
  flex-direction: column;
  gap: 32rpx;
}
</style>
